# -*- mode: python -*-

Import("env")
Import("use_system_version_of_library")

env = env.Clone()

# The collator_icu library and the collator_interface_icu_test unit tests need an environment which
# has access to the third-party ICU headers.
icuEnv = env.Clone()

if not use_system_version_of_library("icu"):
    icuEnv.InjectThirdParty("icu")
    # Since we are injecting the third-party ICU headers, we must also copy the same defines that we
    # use to configure ICU when building ICU sources. See comment in
    # src/third_party/icu4c-57.1/source/SConscript.
    icuEnv.Append(
        CPPDEFINES=[
            ("UCONFIG_NO_BREAK_ITERATION", 1),
            ("UCONFIG_NO_FORMATTING", 1),
            ("UCONFIG_NO_TRANSLITERATION", 1),
            ("UCONFIG_NO_REGULAR_EXPRESSIONS", 1),
            ("U_CHARSET_IS_UTF8", 1),
            ("U_STATIC_IMPLEMENTATION", 1),
            ("U_USING_ICU_NAMESPACE", 0),
        ],
    )

icuEnv.CppUnitTest(
    target="db_query_collation_test",
    source=[
        "collation_bson_comparison_test.cpp",
        "collation_index_key_test.cpp",
        "collator_factory_icu_locales_test.cpp",
        "collator_factory_icu_test.cpp",
        "collator_factory_mock_test.cpp",
        "collator_interface_icu_test.cpp",
        "collator_interface_mock_test.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/db/concurrency/lock_manager",
        "$BUILD_DIR/mongo/db/storage/key_string/key_string",
        "collator_factory_mock",
        "collator_icu",
        "collator_interface",
        "collator_interface_mock",
    ],
)
